﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace FinalProject
{
    public partial class wucNganhNghe : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            dtlNganhNghe.ItemCommand += new DataListCommandEventHandler(dtlNganhNghe_ItemCommand);            
        }

        void dtlNganhNghe_ItemCommand(object source, DataListCommandEventArgs e)
        {            
            int index = e.Item.ItemIndex;
            var item = e.Item;
            Response.Redirect("ChiTietNganhNghe.aspx?id=" + Utility.LstCongViecCurrent[index].ID);
        }

        public void Binding(int n)
        {
            try
            {
                if (Utility.LstCongViecCurrent != null && Utility.LstCongViecCurrent.Count > 0)
                {
                    if (n == 0)
                    {
                        dtlNganhNghe.DataSource = Utility.LstCongViecCurrent;
                        dtlNganhNghe.DataBind();
                    }
                    else
                    {
                        List<CongViec> lst = new List<CongViec>();
                        for (int i = 0; i < Utility.LstCongViecCurrent.Count; i++)
                        {
                            lst.Add(Utility.LstCongViecCurrent[i]);
                            if (i == n - 1)
                                break;
                        }
                        dtlNganhNghe.DataSource = lst;
                        dtlNganhNghe.DataBind();
                    }
                }
            }
            catch { }
        }        
    }
}